
<template>
  <swiper class="swiper" ref="mySwiper" :options="swiperOption">
    <swiper-slide>Resize me 1</swiper-slide>
    <swiper-slide>Resize me 2</swiper-slide>
    <swiper-slide>Resize me 3</swiper-slide>
    <swiper-slide>Resize me 4</swiper-slide>
    <swiper-slide>Resize me 5</swiper-slide>
    <swiper-slide>Resize me 6</swiper-slide>
    <div class="swiper-button-prev" @click="prev" slot="button-prev"></div>
    <div class="swiper-button-next" @click="next" slot="button-next"></div>
  </swiper>
</template>

<script>
import { Swiper, SwiperSlide } from "vue-awesome-swiper";
import "swiper/swiper-bundle.css";
// import "swiper/swiper-bundle.css";

export default {
  name: "swiper-example-change-direction",
  title: "Change direction",
  components: {
    Swiper,
    SwiperSlide,
  },
  data() {
    return {
      swiperOption: {
        slidesPerView: 3,
        spaceBetween: 30,
        direction: "horizontal",
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev",
        },
        on: {
          resize: () => {
            this.$refs.swiper.$swiper.changeDirection(
              window.innerWidth <= 960 ? "vertical" : "horizontal"
            );
          },
        },
      },
    };
  },
  methods: {
    prev() {
      this.$refs.mySwiper.$swiper.slidePrev();
    },
    next() {
      this.$refs.mySwiper.$swiper.slideNext();
    },
  },
};
</script>

<style lang="scss" scoped>
.swiper {
  height: 300px;
  width: 100%;

  .swiper-slide {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-weight: bold;
    font-size: 20px;
    background-color: #fff;
  }
}
</style>